package com.bite.spring.ioc;

import com.bite.spring.ioc.controller.DemoController;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

@SpringBootApplication
public class SpringIoCApplication {

    public static void main(String[] args) {
        ApplicationContext context =  SpringApplication.run(SpringIoCApplication.class, args);
        DemoController bean1 = context.getBean(DemoController.class);
        bean1.print();

        DemoController bean2 = context.getBean("demoController", DemoController.class);
        bean2.print();

        DemoController bean3 = (DemoController) context.getBean("demoController");
        bean3.print();

        System.out.println(bean1);
        System.out.println(bean2);
        System.out.println(bean3);
    }

}
